function output = fn_chi_calibration(chi_avg, s_min, s_max, dist_s)
% This function sets the three targets to calibrate chi(s)

chi3 = s_min;

x0 = [2, 0.3];
options = optimoptions('fsolve','Display','off');

sol = fsolve(@(chi) root2d(chi, chi3, chi_avg, s_min, s_max, dist_s),x0,options);

output = [sol(1), sol(2), chi3];

    function F = root2d(chi, chi3, chi_avg, s_min, s_max, dist_s)
        
        f = @(x) (x - chi3).^chi(2).*pdf(dist_s,x);
        
        F(1) = chi(1)*(s_max - chi3).^chi(2)    - 0.9;
        F(2) = chi(1)*integral(f, s_min, s_max) - chi_avg;
        
    end

end
